﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using XPMVC.Database;

namespace XPMVC.Views
{
    public partial class main : System.Web.UI.MasterPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            linkLogin.Visible = Session["id"] == null;

            using (xpEntities db = new xpEntities())
            {
                if (Session["id"] != null)
                {
                    int id = Int32.Parse(Session["id"].ToString());

                    var user = db.Member.Where(x => x.id.Equals(id)).FirstOrDefault();

                    loginName.Text = user.username + " - you have " + user.points + " points and your maximum bid is " + (user.points * 3);
                }
                else
                {
                    loginName.Text = "Guest, maybe you want to <a href=\"Register.aspx\">register</a>?";
                }
            }
        }
    }
}